import React, { Component } from 'react';
import {
	StyleSheet, Text, View, TouchableOpacity, Alert,
	PixelRatio, Image, ScrollView, Animated
} from "react-native";
import { API, API_GENERATE } from '../../../../config/api';
import MethodUtil from '../../../../utils/MethodUtil';
import { GLOBAL } from '../../../../config/global';
import { CREDIT_TYPES } from '../../../../config/definition';
import { style } from '../../../../theme/style';
import { Common } from '../../../../component/common/Common.js';
import { SpaceBetween } from '../../create/_components/SpaceBetween.js';
import { MorePage } from '../../create/_components/MorePage.js';
import { PlayListPage } from '../../create/_components/PlayListPage.js';
import { ApprovalView, RefuseModal } from '../../../../component/ModalVerifylComponent.js';
import { StateLightBox, LightBox } from '../../../../component/Store';
import { PageStatusIndex } from '../../../../component/page-status/PageStatusIndex';
import HTTP from '../../../../utils/http';
import ToastUtil from '../../../../utils/toast';
import { CURRENCY } from '../../../../utils/helper';
const scale = GLOBAL.SCALE;

const sendData = {};

export class ApprovalDefaultPage extends Component {
	static navigationOptions = ({ navigation, navigationOptions }) => {
		const { params } = navigation.state;
		return {
			headerTitle: params.title,
			headerTintColor: style.color.white,
			headerLeft: <Common type="headLeft" onPress={() => { navigation.goBack() }} color='#fff' />,
			headerRight: (<Image style={style.head.headRightEmpty} source={require('../../../../imgs/goBackEmpty.png')} />),
			headerStyle: style.head.headerStyle,
			headerTitleStyle: {
				flex: 1,
				textAlign: 'center'
			}
		}
	};

	requesting;
	constructor(props) {
		super(props);
		this.orderId = props.navigation.state.params.paramsData.orderId;
		this.orderType = props.navigation.state.params.paramsData.orderType;
		this.companyId = props.navigation.state.params.paramsData.companyId;
		this.businessKey = props.navigation.state.params.paramsData.businessKey;
		this.taskId = props.navigation.state.params.paramsData.taskId;
		this.formKey = props.navigation.state.params.paramsData.formKey;
		this.status = props.navigation.state.params.status;
		this.companyName = props.navigation.state.params.paramsData.companyName;
		this.auditResultName = props.navigation.state.params.paramsData.auditResultName;

		this.animateData = {
			basic: {
				start: {   // 初始值
					value: 120,
					text: '展开更多'
				},
				end: {  // 介素值
					value: 380,
					text: '收起'
				}
			},
		}

		this.state = {
			data: {},
			basicAnim: new Animated.Value(this.animateData.basic.start.value),
			basicOnoff: true,
			loaded: false,
			lightBoxVisible: false,
			stateLightBoxData: false,
			profitList: []
		}

		this._closeLightBox = this._closeLightBox.bind(this);
		this.stateLightBoxData = {
			onClosePress: this._closeLightBox,
			modalVisible: false,
			title: '',
			rowDataList: [],
		};

		this.lightBoxData = {
			onClosePress: this._closeLightBox,
			modalVisible: false,
			title: '',
			rowDataList: [],
		};
	}

	componentWillMount () {
		this._getDetailData(this.orderId);//详情数据
		this._getProfitData(this.orderId);//盈利数据
	}

	//获取盈利数据
	async	_getProfitData (orderId) {
		let responseData = await HTTP.POST(API_GENERATE(API.GET_PROFITANALYSE), { orderId });
		if (responseData) {
			this.setState({
				profitList: responseData
			})
		}
	}

	//初始化详情数据
	async _getDetailData (orderId) {
		this.setState({
			loaded: true
		});

		let responseData = await HTTP.POST(API_GENERATE(API.ORDER_DETAIL), {
			orderId,
			queryType: 'ORDER_ALL_INFO',
		});

		this.setState({
			loaded: false
		});

		if (responseData) {
			this.setState({
				data: responseData
			})
		}
	}

	// animatedFn
	_animatedFn = (num, animateObj) => {
		Animated.timing(
			animateObj,
			{
				duration: 300,
				toValue: num
			}
		).start();
	}

	// 基本信息  更多设置
	_onPressFn = (data, objOnoff, name, animateObj) => {
		console.log('1-data', data, '2-objOnoff', objOnoff, '3-name', name)
		if (objOnoff) {
			this._animatedFn(data.end.value, animateObj);
		} else {
			this._animatedFn(data.start.value, animateObj);
		}
		if (name == 'basicOnoff') {
			this.setState({
				basicOnoff: !objOnoff
			})
		}
	}

	//同意，驳回接口调用
	getApprovalView () {
		const { profitList } = this.state;
		//HASLOT 已审批   LOT未审批
		return (this.status && this.status === 'LOT') ? (
			<View style={{ backgroundColor: '#fff' }}>
				{
					profitList && profitList.length ?
						<View style={{ backgroundColor: '#fff0b3', padding: 10 * scale }}>
							{
								profitList.map((item, index) => {
									<Text key={index} style={{ color: '#cf8300' }}>{item}</Text>
								})
							}
						</View> : null
				}
				<ApprovalView agreePress={() => {
					sendData.status = 'PASS';
					Alert.alert('提示', '确定要同意此成交报告吗？', [
						{
							text: '再想想',
						}, {
							text: '确定',
							onPress: () => {
								this._fetchApproval('1');
							}
						}
					]);

				}} refusePress={() => {
					this.setState({
						refuseModalVisible: true
					})
				}} />
			</View>
		) : null;
	}

	async _fetchApproval (numStr) {
		if (this.requesting) return;
		this.setState({ refuseModalVisible: false, loaded: true });
		this.requesting = true;
		const responseData = await HTTP.POST(API_GENERATE(API.ORDER_TASTK_APPROVAL), {
			businessKey: this.businessKey,
			taskId: this.taskId,
			formKey: this.formKey,
			auditResult: numStr,
			remark: this.remark, // 填写
		});
		this.setState({ loaded: false });
		if (responseData) {
			ToastUtil.showSuccess((numStr == '0') ? '驳回成功' : '审批成功').then(() => { this._goBack(); })
		} else {
			this.requesting = false;
		}
	}

	// 返回上一个页面
	_goBack = () => {
		setTimeout(() => {
			this.requesting = false;
		}, 1000)
		this.props.navigation.goBack();
	}

	_closeLightBox () {
		this.lightBoxData.modalVisible = false;
		this.stateLightBoxData.modalVisible = false;
		const { lightBoxVisible, stateLightBoxData } = this.state;
		this.setState({
			lightBoxVisible: !lightBoxVisible,
			stateLightBoxData: !stateLightBoxData,
		});
	}

	//审批节点
	async	_didPressShowStateLightBox (orderId, processInstanceId) {
		this.setState({
			loaded: true
		});

		//查询审批节点
		let responseData1 = await HTTP.GET(API_GENERATE(API.APPROVAL_NODE) + '?bizId=' + orderId + '&bizObjType=1');

		this.setState({
			loaded: false
		});

		this.stateLightBoxData.modalVisible = true;
		this.stateLightBoxData.title = '审批状态';
		this.stateLightBoxData.rowDataList = responseData1.map((item, index) => {
			return {
				taskName: item.taskName,// + '(' + item.auditStaffName + ')',//auditStaffName
				auditTime: item.auditTime,
				auditResult: item.auditResult,
				remark: item.remark,
				auditStaffName: item.auditStaffName,
				logId: item.logId,
			};
		})

		const { stateLightBoxVisible } = this.state;
		this.setState({
			stateLightBoxVisible: !stateLightBoxVisible
		});
	}

	//预算估计费用
	_didPressShowBudgetLightBox (orderFeeVOS, unit) {
		this.lightBoxData.modalVisible = true;
		this.lightBoxData.title = '费用估算';
		this.lightBoxData.rowDataList = orderFeeVOS.map((item, index) => {
			return { label: item.feeTypeName + '：', val: unit.label + MethodUtil.toThousands(item.feeAmt || 0, 2) + unit.text }
		});

		const { lightBoxVisible } = this.state;
		this.setState({
			lightBoxVisible: !lightBoxVisible
		});
	}

	//批次关联
	async _didPressShowOppoOrderLightBox (data) {
		const { orderTypeName, orderId, itemId } = data;
		let goodsName = '';
		let price = '';
		this.lightBoxData.rowDataList = [];
		this.setState({
			loaded: true
		});

		let responseData1 = await HTTP.POST(API_GENERATE(API.ORDER_DETAIL), {
			orderId,
			itemId,
			queryType: 'ORDER_ALL_INFO',
		});

		this.setState({
			loaded: false
		});
		if (responseData1) {
			if (responseData1.orderItemList && responseData1.orderItemList.length > 0) {
				responseData1.orderItemList.map((item, index) => {
					goodsName += (index === 0 ? '' : ',') + item.goodsName;
					price = item.price;
				})
			}
		}
		this.lightBoxData.modalVisible = true;
		this.lightBoxData.title = orderTypeName + '成交报告';
		this.lightBoxData.rowDataList.push({ label: '成交编号：', val: responseData1.orderId });
		this.lightBoxData.rowDataList.push({ label: '客户名称：', val: responseData1.companyName });
		this.lightBoxData.rowDataList.push({ label: responseData1.orderType === 'S' ? '收款类型：' : '付款类型：', val: responseData1.payTypeName });
		this.lightBoxData.rowDataList.push({ label: responseData1.orderType == 'S' ? '收款方式：' : '付款方式：', val: responseData1.payStyleName });
		this.lightBoxData.rowDataList.push({ label: responseData1.orderType == 'S' ? '收款期限：' : '付款期限：', val: this.getPayTypeName(responseData1.payType) + responseData1.payExpireDays + '天内' + (responseData1.orderType == 'S' ? '收' : '付' + '款') });
		this.lightBoxData.rowDataList.push({ label: '商品名称：', val: goodsName });
		this.lightBoxData.rowDataList.push({ label: '交货方式：', val: responseData1.orderType == 'P' ? responseData1.purchaseDeliveryTypeName : responseData1.saleDeliveryTypeName });
		this.lightBoxData.rowDataList.push({ label: '单价：', val: CURRENCY.getUnit(responseData1.currency).label + (responseData1.orderItemList && responseData1.orderItemList.length > 0 ? MethodUtil.toThousands(responseData1.orderItemList[0].price) : 0) + CURRENCY.getUnit(responseData1.currency).text });

		const { lightBoxVisible } = this.state;
		this.setState({
			lightBoxVisible: !lightBoxVisible
		});
	}

	//意象客户
	async _didPressShowWillCustomLightBox (currency, data) {
		const { itemId, orderId, goodsName } = data;
		this.setState({
			loaded: true
		});

		let responseData1 = await HTTP.POST(API_GENERATE(API.POTENTIAL_CLIENTS_LIST), {
			orderId: orderId,
			itemId: itemId,
		});

		this.setState({
			loaded: false
		});
		console.log('意向客户responseData1', responseData1);
		this.lightBoxData.rowDataList = [];
		this.lightBoxData.modalVisible = true;
		this.lightBoxData.title = '意向客户';
		responseData1.map((item, index) => {
			/*先客户 、商品、数量、单价、时间、类型、
			地址、物流费用、财务费用、资源平衡*/
			let { planLogisticsCost, planFinanceCost, planRemark, companyAddressName, planSellQuantity, companyName, planSellBeginDate, planSellEndDate, planSellPrice, planRecvTypeName } = item;
			this.lightBoxData.rowDataList.push({ label: '拟销售客户：', val: companyName });
			this.lightBoxData.rowDataList.push({ label: '拟销售商品：', val: goodsName });
			this.lightBoxData.rowDataList.push({ label: '拟销售数量：', val: planSellQuantity + '吨' });
			this.lightBoxData.rowDataList.push({ label: '拟销售单价：', val: CURRENCY.getUnit(currency).label + MethodUtil.toThousands(planSellPrice) + CURRENCY.getUnit(currency).text });
			this.lightBoxData.rowDataList.push({ label: '拟销售时间：', val: planSellBeginDate + '至' + planSellEndDate });
			this.lightBoxData.rowDataList.push({ label: '拟收款类型：', val: planRecvTypeName });
			this.lightBoxData.rowDataList.push({ label: '拟收货地址：', val: companyAddressName });
			if (planLogisticsCost) {
				this.lightBoxData.rowDataList.push({ label: '物流费用：', val: CURRENCY.getUnit(currency).label + MethodUtil.toThousands(planLogisticsCost) + CURRENCY.getUnit(currency).text });
			}
			if (planFinanceCost) {
				this.lightBoxData.rowDataList.push({ label: '财务费用：', val: CURRENCY.getUnit(currency).label + MethodUtil.toThousands(planFinanceCost) + CURRENCY.getUnit(currency).text });
			}
			if (planRemark) {
				this.lightBoxData.rowDataList.push({ label: '资源平衡：', val: planRemark });
			}
		})


		const { lightBoxVisible } = this.state;
		this.setState({
			lightBoxVisible: !lightBoxVisible
		});
	}

	getPayTypeName (payType) {
		if ('3' === payType) {
			return '货到';
		}
		else if ('4' === payType) {
			return '签订';
		}
		else if ('5' === payType) {
			return '票到';
		} else {
			return '签订';
		}
	}

	render () {
		let { data, basicOnoff, basicAnim } = this.state;
		let { priceType, deliveryType, isPlanSell, currencyName, outOrderPayMethodList, companyName, orderId, payTypeName, baseDateSettleName, prepayRate, payStyleName, payExpireDays,
			deliveryExpireDays, exeBeginDate, periodType, currency, saleDeliveryTypeName, purchaseDeliveryTypeName, lostRenderName, orderItemList, creditInfo,
			payType, orderFeeList, otherCost, orderDeliveryPlanList, orderType, orderMappingList, lostRate,
			freeDays, settleDisputesName, companyContactorName, bizStaffName, processInstanceId } = data;
		const approvalView = this.getApprovalView();
		let basicCss = basicOnoff ? { height: basicAnim } : null;
		return (
			<View style={styles.container}>
				<View style={styles.emptyBg}>
				</View>
				<ScrollView style={{ paddingTop: 10 * scale }}>
					<View style={styles.itemBox}>
						<Animated.View style={[basicCss, styles.animateBg]}>
							<Text style={styles.itemTitle}>基本信息</Text>
							<SpaceBetween fontLeft={{ title: '成交编号' }} fontRight={{ title: orderId }} />
							<SpaceBetween fontLeft={{ title: orderType === 'S' ? '客户' : '供应商' }} fontRight={{ title: companyName }} />
							<SpaceBetween fontLeft={{ title: '申请人' }} fontRight={{ title: bizStaffName }} />
							<SpaceBetween fontLeft={{ title: orderType === 'S' ? '收款类型' : '付款类型' }} fontRight={{ title: payTypeName }} />
							{CREDIT_TYPES[orderType] && CREDIT_TYPES[orderType][payType] && periodType !== 'L' ? <Text style={styles.credit}>授信可用金额 {CURRENCY.getUnit(currency).label + MethodUtil.toThousands(creditInfo && creditInfo.limitAmount) + CURRENCY.getUnit(currency).text}  有效期至{creditInfo && creditInfo.creditEndDate}</Text> : null}
							{prepayRate ? <SpaceBetween fontLeft={{ title: '定金比例' }} fontRight={{ title: prepayRate + '%' }} /> : null}
							{payExpireDays ? <SpaceBetween fontLeft={{ title: this.getPayTypeName(payType) }} fontRight={{ title: payExpireDays + '天内' + (orderType === 'S' ? '收' : '付') + '款' }} /> : null}
							{deliveryExpireDays && '4' === payType ? <SpaceBetween fontLeft={{ title: '款到' }} fontRight={{ title: deliveryExpireDays + '天内交货' }} /> : null}
							{payStyleName ? <SpaceBetween fontLeft={{ title: orderType === 'S' ? '收款方式' : '付款方式' }} fontRight={{ title: payStyleName }} /> : null}
							{/* <SpaceBetween fontLeft={{ title: orderType === 'S' ? '收款比例' : '付款比例' }} fontRight={{ title: '' + '%' }} /> */}
							{currency ? <SpaceBetween fontLeft={{ title: '币种' }} fontRight={{ title: currency }} /> : null}
							{outOrderPayMethodList ? outOrderPayMethodList.map((payItem, i) => {
								return (
									<View>
										<SpaceBetween fontLeft={{ title: orderType === 'S' ? '收款方式' : '付款方式' }} fontRight={{ title: payItem.payMethodName }} />
										<SpaceBetween fontLeft={{ title: orderType === 'S' ? '收款比例' : '付款比例' }} fontRight={{ title: MethodUtil.countObj.multiply(payItem.prepayRate, 100) + '%' }} />
									</View>
								)
							}) : null}
							<SpaceBetween fontLeft={{ title: '币种' }} fontRight={{ title: currencyName || '人民币' }} />
							{baseDateSettleName ? <SpaceBetween fontLeft={{ title: '结算基准日期' }} fontRight={{ title: baseDateSettleName }} /> : null}
							<SpaceBetween fontLeft={{ title: '交货方式' }} fontRight={{ title: orderType == 'P' ? purchaseDeliveryTypeName : saleDeliveryTypeName }} />
							{lostRenderName && deliveryType && 'U' != deliveryType ? <SpaceBetween fontLeft={{ title: '运损承担方' }} fontRight={{ title: lostRenderName }} /> : null}
							{lostRate ? <SpaceBetween fontLeft={{ title: '途损率' }} fontRight={{ title: '千分之' + MethodUtil.countObj.multiply(lostRate, 1000) }} /> : null}
							{freeDays ? <SpaceBetween fontLeft={{ title: '免仓期' }} fontRight={{ title: freeDays }} /> : null}
							{companyContactorName ? <SpaceBetween fontLeft={{ title: '对方企业业务员' }} fontRight={{ title: companyContactorName }} /> : null}
							{settleDisputesName ? <SpaceBetween fontLeft={{ title: '争议处理方式' }} fontRight={{ title: settleDisputesName }} /> : null}
						</Animated.View>
						<MorePage text={basicOnoff ? this.animateData.basic.start.text : this.animateData.basic.end.text} onPressFn={() => { this._onPressFn(this.animateData.basic, basicOnoff, 'basicOnoff', basicAnim) }} />
					</View>

					{
						orderItemList && orderItemList.length > 0 ? (
							orderItemList.map((item, index) => {
								let deliveryAddress = '';
								deliveryAddress = item.deliveryAddressList ? item.deliveryAddressList.map((addr, i) => {
									const address = (addr.cityName ? addr.cityName : '')
										+ (addr.areaName ? addr.areaName : '') + (addr.provinceName ? addr.provinceName : '') + (addr.detailAddress ? addr.detailAddress : '');
									return deliveryAddress += address + (i === (item.deliveryAddressList.length - 1) ? '' : '，');
								}) : '';

								let endAddress = '';
								endAddress = item.endAddressList ? item.endAddressList.map((addj, j) => {
									/*const addressEnd =  (addj.cityName ? addj.cityName : '')
									+ (addj.areaName ? addj.areaName : '')+(addj.provinceName ? addj.provinceName : '')  + (addj.detailAddress ? addj.detailAddress : '');*/
									const addressEnd = (addj.detailAddress ? addj.detailAddress : '');
									return endAddress += addressEnd + (j === (item.endAddressList.length - 1) ? '' : '，');
								}) : ''

								return (
									<View key={index}>
										<View style={[styles.itemBox, styles.borders]}>
											<View style={[styles.animateBg]}>
												<Text style={styles.itemTitle}>{item.goodsName}</Text>
												<SpaceBetween fontLeft={{ title: '数量' }} fontRight={{ title: item.quantity + item.uomName }} />
												<View style={styles.infoBlue}>
													<Text style={styles.infoText}>
														总库存：{item.inventoryStandBookVO && item.inventoryStandBookVO.comAvailableQuantity ? item.inventoryStandBookVO.comAvailableQuantity : '0'}{item.uomName}，
													部门库存：{item.inventoryStandBookVO && item.inventoryStandBookVO.orgAvailableQuantity ? item.inventoryStandBookVO.orgAvailableQuantity : '0'}{item.uomName}
													</Text>
													<Text style={styles.infoText}>
														总敞口：{item.inventoryStandBookVO && item.inventoryStandBookVO.comOpenQuantity ? item.inventoryStandBookVO.comOpenQuantity : '0'}{item.uomName}，
													部门敞口：{item.inventoryStandBookVO && item.inventoryStandBookVO.orgOpenQuantity ? item.inventoryStandBookVO.orgOpenQuantity : '0'}{item.uomName}
													</Text>
												</View>
												<View style={styles.viewWidthBottomBorder}>
													{
														orderType === 'S' ? <SpaceBetween
															fontLeft={{ title: '当月客户计划完成率' }}
															fontRight={{ title: MethodUtil.setPercent(item.demandExecuteMonth, item.demandMonth) }} />
															: null
													}
													{
														orderType === 'S' ? <SpaceBetween
															fontLeft={{ title: '部门计划完成率' }}
															fontRight={{
																title: MethodUtil.setPercent(item.salePlanExecuteMonth, item.salePlanMonth)
															}} />
															: null
													}
												</View>

												<SpaceBetween fontLeft={{ title: priceType == '2' ? '暂定价' : '单价' }} fontRight={{ title: CURRENCY.getUnit(currency).label + MethodUtil.toThousands(item.price || 0) + CURRENCY.getUnit(currency).text + '/' + item.uomName }} />
												{item.priceFormlaId ? <SpaceBetween fontLeft={{ title: '计价公式' }} fontRight={{ title: item.priceFormulaDesc }} /> : null}
												{item.udPrice ? <SpaceBetween fontLeft={{ title: '升贴水' }} fontRight={{ title: (item.udPrice >= 0 ? '+' : '') + item.udPrice + CURRENCY.getUnit(currency).text + '/' + item.uomName }} /> : null}
												{item.remark ? <SpaceBetween fontLeft={{ title: '套期保值' }} fontRight={{ title: item.remark }} /> : null}
												{/* <View style={styles.newPrice}>
												<View style={styles.newPriceBg}>
													<Text style={styles.priceTitle}>市场价参考：</Text>
													<Text style={styles.price}>4000</Text>
													<Image source={require('../../../../imgs/my-siter/up.png')} style={{ height: 10 * scale, marginLeft: 3 * scale }} />
												</View>
											</View> */}
												{deliveryAddress && deliveryAddress != '' ? <SpaceBetween fontLeft={{ title: '出库地点' }} fontRight={{ title: deliveryAddress }} /> : null}
												{endAddress && endAddress != '' ? <SpaceBetween fontLeft={{ title: '目的地' }} fontRight={{ title: endAddress }} /> : null}
												{item.logisticsPrice && deliveryType && 'U' != deliveryType ? <SpaceBetween fontLeft={{ title: '运输单价' }} fontRight={{ title: CURRENCY.getUnit(currency).label + MethodUtil.toThousands(item.logisticsPrice) + CURRENCY.getUnit(currency).text + '/' + item.uomName }} /> : null}
												{item.transportTypeName && deliveryType && 'U' != deliveryType ? <SpaceBetween fontLeft={{ title: '运输方式' }} fontRight={{ title: item.transportTypeName }} /> : null}
												{item.deliveryBeginDate && item.deliveryEndDate ? <SpaceBetween fontLeft={{ title: '交货起始日期' }} fontRight={{ title: item.deliveryBeginDate + '至' + item.deliveryEndDate }} /> : null}
												{item.ysPercent ? <SpaceBetween fontLeft={{ title: '溢短装比率' }} fontRight={{ title: MethodUtil.countObj.multiply(item.ysPercent, 100) + '%' }} /> : null}
												<View style={styles.viewWidthTopBorder}>
													<SpaceBetween fontLeft={{ title: '总价' }} fontRight={{ title: CURRENCY.getUnit(currency).label + MethodUtil.toThousands(item.amount || 0) + CURRENCY.getUnit(currency).text, style: { color: style.color.pink } }} />
												</View>
											</View>
										</View>
										{
											isPlanSell && isPlanSell == 1 ? <View style={[styles.itemBox, styles.borders]}>
												<Text style={styles.itemTitle}>意向客户</Text>
												<TouchableOpacity activeOpacity={0.5} onPress={() => { this._didPressShowWillCustomLightBox(currency, item) }} style={[styles.budget]}>
													<SpaceBetween iconShow={true} fontLeft={{ title: item.goodsName + '意向客户', style: { width: 150 * scale } }} fontRight={{ title: '查看详情' }} iconShow={true} />
												</TouchableOpacity>
											</View> : null
										}
									</View>
								)
							})
						) : null
					}

					{
						orderMappingList && orderMappingList.length > 0 ?
							<View style={[styles.itemBox, styles.borders]}>
								<Text style={styles.itemTitle}>关联{orderType === 'S' ? '采购' : '销售'}</Text>
								{
									orderMappingList.map((item, index) => {
										return (
											<TouchableOpacity key={index} activeOpacity={0.5} onPress={() => {
												this._didPressShowOppoOrderLightBox({
													orderTypeName: orderType === 'S' ? '采购' : '销售',
													orderId: orderType === 'S' ? item.purchaseOrderId : item.salesOrderId,
													itemId: orderType === 'S' ? item.purchaseOrderItemId : item.salesOrderItemId
												}
												)
											}}>
												<SpaceBetween iconShow={true} fontLeft={{ title: item.goodsName }} fontRight={{ title: '匹配' + (orderType === 'S' ? '采购' : '销售') + '数量：' + (item.quantity || '0') + (item.uomName || '吨') }} />
											</TouchableOpacity>
										)
									})
								}
							</View>
							: null
					}

					{
						orderFeeList && orderFeeList.length ?
							<View style={[styles.itemBox, styles.borders]}>
								<Text style={styles.itemTitle}>费用估算</Text>
								<TouchableOpacity activeOpacity={0.5} onPress={() => { this._didPressShowBudgetLightBox(orderFeeList, CURRENCY.getUnit(currency)) }} style={[styles.budget]}>
									<SpaceBetween iconShow={true} fontLeft={{ title: '总价' }} fontRight={{ title: CURRENCY.getUnit(currency).label + MethodUtil.toThousands((otherCost || 0)) + CURRENCY.getUnit(currency).text }} />
								</TouchableOpacity>
							</View> : null
					}
					{
						orderDeliveryPlanList && orderDeliveryPlanList.length > 0 ? (
							<View style={[styles.itemBox, styles.borders]}>
								<Text style={styles.itemTitle}>交货计划</Text>{
									orderDeliveryPlanList.map((item, index) => {
										return (
											<PlayListPage key={index} data={{ goodsName: item.goodsName, time: item.deliveryBeginDate + '至' + item.deliveryEndDate, quie: item.quantity }} />
										)
									})
								}
							</View>

						) : null
					}

					<StateLightBox  {...this.stateLightBoxData} textStyle={{ marginLeft: 15 * scale, marginRight: 5 * scale }} />
					<LightBox {...this.lightBoxData} />
				</ScrollView>

				<TouchableOpacity style={styles.paiziBox} onPress={() => { this._didPressShowStateLightBox(orderId) }} activeOpacity={1}>
					<Image style={styles.paiziBg} source={require('../../../../imgs/apply/topTitle.png')} />
					<View style={styles.paizi}>
						<Text style={styles.topLeft}>{this.auditResultName}</Text>
						<Text style={styles.topRight}>{companyName ? companyName : this.companyName}</Text>
					</View>
				</TouchableOpacity>

				{approvalView}
				<RefuseModal visible={this.state.refuseModalVisible} btnPress={(remark) => {
					this.remark = remark;
					this._fetchApproval('0');
				}} bgPress={() => {
					this.setState({
						refuseModalVisible: false,
					});
				}} />
				{
					this.state.loaded ?
						<View style={{ position: 'absolute', height: '100%', width: '100%', top: 0 }}>
							<PageStatusIndex status='loading' />
						</View>
						: null
				}
			</View>
		)
	}
}
const styles = StyleSheet.create({
	ocrWrap: {
		width: 375 * scale,
		height: GLOBAL.SCREEN_HEIGHT,
		backgroundColor: 'rgba(0, 0, 0, 0)',
		justifyContent: 'center',
		alignItems: 'center',
	},
	loadedCell: {
		width: 75 * scale,
		height: 75 * scale,
		backgroundColor: 'rgba(0, 0, 0, .5)',
		borderRadius: 7,
		justifyContent: 'center',
		alignItems: 'center',
	},
	container: {
		flex: 1,
		backgroundColor: style.color.white,
	},
	emptyBg: {
		height: 39 * scale,
		backgroundColor: style.color.themeColor,
		marginBottom: 13 * scale,
	},
	paiziBox: {
		width: 351 * scale,  // 726
		height: 60 * scale,
		position: 'absolute',
		left: 12 * scale,
		top: 8 * scale
	},
	paizi: {
		flexDirection: 'row',
		height: 48 * scale,
		justifyContent: 'space-between',
		alignItems: 'center',
		paddingLeft: 15 * scale,
		paddingRight: 15 * scale,
		paddingTop: 10 * scale
	},
	paiziBg: {
		width: 351 * scale,
		position: 'absolute',
	},
	budget: {
		flexDirection: 'row',
		justifyContent: 'space-between',
		alignItems: 'center',
	},
	topLeft: {
		fontSize: 14 * scale,
		color: style.color.themeColor,
	},
	topRight: {
		fontSize: 13 * scale,
		color: '#222',
	},
	itemBox: {
		paddingLeft: 12 * scale,
		paddingRight: 12 * scale,
		paddingBottom: 13 * scale,
		backgroundColor: '#fff'
	},
	itemTitle: {
		fontSize: 14 * scale,
		color: style.color.themeColor,
		height: 20 * scale,
		lineHeight: 20 * scale,
		marginTop: 12 * scale,
		marginBottom: 12 * scale
	},
	borders: {
		borderTopWidth: 12 * scale,
		borderStyle: 'solid',
		borderTopColor: style.color.dullGrey,
	},
	infoBlue: {
		width: '100%',
		backgroundColor: style.color.infoBlue,
		borderRadius: 4 * scale,
		paddingTop: 5 * scale,
		paddingBottom: 5 * scale,
		paddingLeft: 8 * scale,
		paddingRight: 8 * scale,
		marginTop: 5 * scale,
		marginBottom: 5 * scale
	},
	infoText: {
		fontSize: 12 * scale,
		color: '#2F7BFF'
	},
	viewWidthTopBorder: {
		borderTopWidth: 1 / PixelRatio.get(),
		borderStyle: 'solid',
		borderBottomColor: style.color.border,
		marginTop: 6 * scale,
		paddingTop: 6 * scale,
	},
	viewWidthBottomBorder: {
		borderBottomWidth: 1 / PixelRatio.get(),
		borderStyle: 'solid',
		borderBottomColor: style.color.border,
		marginTop: 6 * scale,
		paddingTop: 6 * scale,
	},
	newPrice: {
		position: 'relative',
		height: 40 * scale
	},
	newPriceBg: {
		height: 24 * scale,
		paddingLeft: 15 * scale,
		paddingRight: 15 * scale,
		flexDirection: 'row',
		justifyContent: 'center',
		alignItems: 'center',
		backgroundColor: '#EDF3FF',
		marginBottom: 15 * scale,
		borderRadius: 12 * scale,
		position: 'absolute',
		top: 0,
		left: 0
	},
	priceTitle: {
		fontSize: 10 * scale,
		color: '#222',
	},
	price: {
		color: style.color.taps,
		fontSize: 13 * scale
	},
	lotBox: {
		borderTopWidth: 1 / PixelRatio.get(),
		borderStyle: 'solid',
		borderTopColor: style.color.border,
		height: 60 * scale,
		flexDirection: 'row',
		alignItems: 'center'
	},
	lotItem: {
		flexDirection: 'row',
		justifyContent: 'center',
		alignItems: 'center',
	},
	lotText: {
		width: '50%',
		height: 20 * scale,
		fontSize: 18 * scale,
		color: style.color.dark,
		marginLeft: 15 * scale,
		borderRightWidth: 2 * scale,
		borderStyle: 'solid',
		borderRightColor: style.color.border,
	},
	animateBg: {
		backgroundColor: style.color.white
	},
	credit: {
		fontSize: 13 * scale,
		color: '#f86765',
		padding: 4 * scale
	}
})